<?php

require_once($_SERVER['DOCUMENT_ROOT'].'/includes/site_defaults.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/database/db.php');

if (!isset($_SESSION)) {
	session_start();
}


if (isset($_GET['dealer_id']) && $_GET['dealer_id'] > 0) {
	
	// when this page is called, increase the "view" count
	mysql_select_db($db_name, $db);
 	
	$u_qry = sprintf("UPDATE dealerships SET num_views = num_views + 1 WHERE id = %s", $_GET['dealer_id']);
	mysql_query($u_qry);

	// get the dealer info
	$qry = sprintf("SELECT *
		FROM dealerships
		WHERE id = %s", $_GET['dealer_id']);
	$rs = mysql_query($qry);
	$dealer = mysql_fetch_assoc($rs) or die("Unable to get information.");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="robots" content="nofollow, noindex" />
	<title>UnOfficial Green Auto Market Home Page</title>
	<link href="<?php echo $site_root."css/green.css"; ?>" rel="stylesheet" type="text/css" />
	<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/jquery-ui.js" type="text/javascript" charset="utf-8"></script> 	

</head>

<body>


	<?php include($header); ?>
	<?php include($navigation); ?>
	<div id="wrapper">
		<div id="contentcontainer">
			<div id="content">
				<table border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td>Dealer: </td>
						<td><?php echo $dealer["dealer_name"] ?></td>
					</tr>
					<tr>
						<td>Address:</td>
						<td><?php echo $dealer["address1"] ?></td>
					</tr>
					<?php if(! empty($dealer["address2"])): ?>
						<tr>
							<td>&nbsp;</td>
							<td><?php echo $dealer["address2"] ?> </td>
						</tr>
					<?php endif; ?>
					<tr>
						<td>City:</td>
						<td><?php echo $dealer["city"] ?></td>
					</tr>
					<tr>
						<td>State:</td>
						<td><?php echo $dealer["state_province"] ?></td>
					</tr>
					<tr>
						<td>Zip:</td>
						<td><?php echo $dealer["zip_postal"] ?></td>
					</tr>
					<tr>
						<td>Description:</td>
						<td><?php echo $dealer["description"] ?></td>
					</tr>
				</table>
				<hr />

				Email the Dealership
				<form action="sendmail.php" name="email_dealer_form" method="post">
					<input type="hidden" name="contact_id" value="<?php echo $dealer["contact_id"] ?>" id="contact_id"/>
					<input type="hidden" name="dealer_id" value="<?php echo $dealer["id"] ?>" id="dealer_id"/>
					<textarea name="message" rows="8" cols="40"></textarea>
					<br />
					<input type="submit" value="Send">
					<button type="button" onclick="$('#dealer_<?php echo $dealer["id"] ?>').slideUp('slow');">Cancel</button>
				</form>

				
			</div><!--End of Content-->

		</div><!--End of Content Container-->
	</div><!--End of Wrapper-->
	<?php include($footer); ?>
</body>

</html>